#include<cstdio>
int main(){
	int x;
	int y;
	int n[9][9];
	for(int f=0;f<9;f++){
  		for(int g=0;g<9;g++){
			n[f][g]=0;
		}
	}
	int count=1;
	while(1){
		printf("  123456789\n");
		printf("  ---------\n");
		for(int e=0;e<9;e++){
			printf("%d|",e+1);
			for(int r=0;r<9;r++){
				if(n[e][r]==0){
					printf(" ");
				}
				else{
					printf("%d",n[e][r]);
				}
			}
			printf("|%d",e+1);
			printf("\n");
		}
		printf("  ---------\n");
		printf("  123456789\n");
		if(count%2==1){
			printf("Player1:");
			scanf("%d %d",&x,&y);
		}
		else{
			printf("Player2:");
			scanf("%d %d",&x,&y);
		}
		if(x==0 || y==0){
			break;
		}
		else if(((x<=9||y<=9) && (x>0 || y>0)) && (n[y-1][x-1]!=1 && n[y-1][x-1]!=2)){
			if(count%2==0){
				n[y-1][x-1]=2;
			}
			else{
				n[y-1][x-1]=1;
			}
			count++;
		}
	}
}
